﻿@{ 
    string MailBox = ViewBag.MailBox;
    string MailBoxName = "";
    bool IsTrash = MailBox == "trash"; 
    TBM.Models.Mail MailInfo = (TBM.Models.Mail)ViewBag.Mail;

    switch(MailBox){
        case "inbox":
            MailBoxName = "收件箱";
            break;
        case "send":
            MailBoxName = "发件箱";
            break;
        case "draft":
            MailBoxName = "草稿箱";
            break;
        case "trash":
            MailBoxName = "垃圾箱";
            break;
    }
}
<div class="mail-line">
</div>

@if(ViewBag.FindMail){
<div class="inbox-header inbox-view-header">
    <h1 class="pull-left">
        @MailInfo.Subject <a href="@("#" + TBM.Core.App.ToBase64("action=/Mail/&mailbox=" + MailBox))" data-title="Inbox">@MailBoxName </a>
    </h1>
    <div class="pull-right">
        
    </div>
</div>
<div class="inbox-view-info">
    <div class="row">
        <div class="col-md-7">
            <p>
                <label class="bold">来自：</label> 
                <img src="@MailInfo.MailFrom.PicUrl" height="20">
                <span class="bold">@MailInfo.MailFrom.FullName </span><span>&lt;@MailInfo.MailFrom.UID&gt; </span>
            </p>
            <p>
                <label class="bold">日期：</label> @MailInfo.CreateDate.ToString("yyyy-MM-dd hh:mm:ss")
            </p>
            <p id="receiver">
                <label class="bold">发至：</label> 
                @if(MailBox == "inbox"){
                    <label class="bold">我</label>
                }else{
                    int Count = MailInfo.MailTo.Count;
                    for(int i = 0; i < Count; i++){
                        <label data-toggle="tooltip" data-avatar="@MailInfo.MailTo[i].PicUrl" data-uid="@MailInfo.MailTo[i].UID">
                            @MailInfo.MailTo[i].FullName 
                        </label>
                        if(i < Count - 1){
                            @(",")
                        }
                    }
                    <script type="text/javascript">
                        $("#receiver [data-toggle='tooltip']").tooltip({
                            html: true,
                            placement: "bottom",
                            template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
                            title: function () {
                                var tool = $(this);
                                return '<img src="' + tool.data("avatar") + '" height="20" /> ' +
                                        tool.text() +
                                        '&lt;' + tool.data("uid") + '&gt;';
                            }
                        });
                    </script>
                }
            </p>
        </div>
        <div class="col-md-5 inbox-info-btn">
            <div class="btn-group">
                @if(!ViewBag.MailFromMe){
                <button class="btn blue reply-btn mail-menu-link" data-target="/Mail/Editor?mid=@MailInfo.ID&type=reply" data-type="Reply">
                    <i class="fa fa-reply"></i> 回复
                </button>
                }else{
                <button class="btn blue reply-btn mail-menu-link" data-target="/Mail/Editor?mid=@MailInfo.ID&type=forward" data-type="Reply">
                    <i class="fa fa-mail-forward"></i> 转发
                </button>
                }
                <button class="btn blue dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                    <i class="fa fa-angle-down"></i>
                </button>
                <ul class="dropdown-menu pull-right mail-operation">
                    @if(!IsTrash){
                    <li><a href="~/Mail/MarkRead?read=false&mid=@MailInfo.ID" data-type="MarkRead"><i
                        class="fa fa-eye-slash"></i> 标记未读 </a></li>
                    }
                    @if(!ViewBag.MailFromMe){
                    <li><a class="mail-menu-link" href="~/Mail/Editor?mid=@MailInfo.ID&type=reply" data-type="Reply"><i class="fa fa-mail-reply"></i> 回复 </a></li>
                    }
                    <li><a class="mail-menu-link" href="~/Mail/Editor?mid=@MailInfo.ID&type=forward" data-type="Forward"><i class="fa fa-mail-forward"></i> 转发 </a></li>
                    <li class="divider"></li>
                    @if(!IsTrash){
                    <li><a href="~/Mail/MarkDelete?mid=@MailInfo.ID" data-type="MarkDelete"><i class="fa fa-remove">
                    </i>删除 </a></li>
                    }else{
                    <li><a href="~/Mail/Restore?mid=@MailInfo.ID" data-type="Restore"><i class="fa fa-history"></i> 恢复 </a></li>
                    <li><a href="~/Mail/Delete?mid=@MailInfo.ID" data-type="Delete"><i class="fa fa-remove"></i> 永久删除 </a></li>
                    }
                </ul>
            </div>
        </div>
    </div>
</div>
<div class="inbox-view">
    @Html.Raw(MailInfo.Context)
</div>
    if(ViewBag.SetToRead){
    <script type="text/javascript">
        Mail.SetMailToRead();
    </script>
    }
}